package model.elements;

import model.collisions.CollisionCategory;
import model.elements.ArtificialIntelligence.ArtificialIntelligence;
import model.elements.attributes.Coordinate2D;
import model.elements.attributes.Damage;
import model.elements.behaviours.DoesDamage;
import model.elements.configurations.NonPlayerCharacterConfig;
import model.elements.states.weapon.ElementWeaponState;
import model.exceptions.CommandFactoryIsNotReady;
import model.exceptions.ModelExceptions;

// TODO: Auto-generated Javadoc
/**
 * La clase NonPlayerCharacter.
 * La clase NPC tiene (ademas del comportamiento heredado de character) la caracteristica de poseer una IA. 
 * Este tipo de elemento entonces toma nuevos comandos cada turno de la misma.
 * Otra particularidad del NPC es que hace daño al contacto con cualquier otro elemento que reciba daño de el.
 */
public class NonPlayerCharacter extends Character implements DoesDamage
{
	
	/** La inteligencia artificial que tiene asignada. */
	ArtificialIntelligence 	m_ArtificialIntelligence;
	
	/** El daño que hace a los elementos que colisionan con el. */
	Damage					m_damage;
	
	/**
	 * Instantiates a new non player character.
	 *
	 * @param startingPosition the starting position
	 * @param config the config
	 * @throws ModelExceptions the model exceptions
	 */
	public NonPlayerCharacter( Coordinate2D startingPosition, NonPlayerCharacterConfig config ) throws ModelExceptions
	{
		super(startingPosition);
		m_lives 					= config.getLives();
		m_speed 					= config.getSpeed();
		m_equippedWeapon			= config.getWeapon();
		m_ArtificialIntelligence	= config.getNonPlayerCharacterIA();
		m_damage					= config.getDamage();
		m_lifeState.setCategory( config.getCollisionCategory() );
		m_lifeState.setCommand( m_ArtificialIntelligence.getCommand(this) );
	}
	
	/* (non-Javadoc)
	 * @see model.elements.Character#update()
	 */
	@Override
	public void update() throws ModelExceptions
	{
		super.update();
		m_lifeState.setCommand( m_ArtificialIntelligence.getCommand(this) );
	}
	
	/* (non-Javadoc)
	 * @see model.elements.behaviours.DoesDamage#doDamage()
	 */
	@Override
	public Damage doDamage() 
	{
		return m_damage;
	}

	/* (non-Javadoc)
	 * @see model.elements.Character#getCollisionCategory()
	 */
	@Override
	public CollisionCategory getCollisionCategory() 
	{
		return m_lifeState.getCategory();
	}

	/* (non-Javadoc)
	 * @see model.elements.Character#onDeath()
	 */
	@Override
	public void onDeath() throws CommandFactoryIsNotReady, ModelExceptions 
	{}
	
	/* (non-Javadoc)
	 * @see model.elements.behaviours.UsesWeapon#setWeapon(model.elements.states.weapon.ElementWeaponState)
	 */
	@Override
	public void setWeapon(ElementWeaponState weapon) throws ModelExceptions
	{
	}

}
